﻿
using Mono.Cecil;

public class FieldAstTree : LuaAstTree
{
    public LuaFieldReference Field { get; }
    public LuaAstTree? Self { get; }
    public FieldAstTree(LuaFieldReference field)
    {
        Field = field;
        ResultType = field.Type.StackType;
    }
    public FieldAstTree(LuaAstTree self, LuaFieldReference field)
    {
        Self = self;
        Field = field;
        ResultType = field.Type.StackType;
    }
    public override void WriteTo(ICodeWriter writer)
    {
        if (Self != null)
            Self.WriteTo(writer);
        else
            writer.Code(Field.Type.FullName);
        writer.Code($".{Field.Name}");
    }
}
